fix(gateway): warn once on unknown message types#450
Conversation
Data sampling logged a warning per message when a topic's message type package was not installed, flooding the log on stacks with custom messages. Warn once per type, then skip resampling that type. Closes #446
There was a problem hiding this comment.
Pull request overview
Reduces gateway log flooding during topic sampling when encountering ROS message types that cannot be deserialized (e.g., packages/typesupport not available), by warning only on first occurrence and skipping subsequent deserialize attempts for the same type. This aligns with the gateway’s operational goal of remaining usable on stacks that include custom/optional message packages.
Changes:
- Track message types that raise
TypeNotFoundErrorand short-circuit sampling for those types on future samples. - Make the “warn once” behavior thread-safe via a mutex-protected set shared across parallel samplers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/ros2_medkit_gateway/src/data/ros2_topic_data_provider.cpp |
Adds skip-fast-path for previously seen unknown types and warns only on first sighting (mutex-guarded). |
src/ros2_medkit_gateway/include/ros2_medkit_gateway/data/ros2_topic_data_provider.hpp |
Introduces unsupported_types_ tracking state (mutex + set) to support warn-once/skip behavior. |
bburda
left a comment
There was a problem hiding this comment.
Verified the warn-once logic. The pre-check and the catch-block insert are both under the mutex, so it warns about an unknown type once and short-circuits later samples without crashing. Class already deletes copy/move, so the new mutex member is fine. CI green.
Dismissing to complete a deeper review before sign-off.
Address review: cap the warn-once cache at 4096 entries so a graph advertising many distinct unknown types cannot grow it without limit, and surface its size as unsupported_type_count in stats() / x_medkit_stats().
When a topic uses a message type whose package is not installed, the data sampler caught
TypeNotFoundErrorand logged a warning on every sample (ros2_topic_data_provider.cpp), flooding the gateway log on stacks with custom messages.Now the first occurrence of an unknown type is warned once and the type is recorded; subsequent samples of that type short-circuit before the deserialize attempt instead of re-logging. Access is guarded by a mutex (the sampling path runs in parallel).
Verified:
colcon build --packages-up-to ros2_medkit_gatewaycompiles; clang-format-18 clean.Closes #446